unit App.Action.TAppDefaultGridExportExcelAction;

interface

uses SmallStruct.Action,
  App.Action.TAppCustomeAction;

type
  TAppDefaultGridExportExcelAction = class(TAppCustomeAction)
  protected
    function DoPerform(ActionContext: ISSActionContext): Boolean; override;
  end;

implementation

uses
  Dialogs,
  cxExportGrid4Link,
  SmallStruct.View.TSSDataGridView;

{ TAppDefaultGridExportExcelAction }

function TAppDefaultGridExportExcelAction.DoPerform(ActionContext: ISSActionContext): Boolean;
var
  SaveDialog: TSaveDialog;
begin
  SaveDialog := TSaveDialog.Create(self);
  SaveDialog.Filter := 'ALL files (*.xls)|*.XLS';
  try
    if SaveDialog.Execute then
      ExportGrid4ToExcel(SaveDialog.FileName, (ActionContext.GetRequestView.GetObjectInstance as TSSDataGridView)._Grid);
  finally
    SaveDialog.Free;
  end;
end;

end.
